import 'package:flutter/material.dart';

class TabbarNavTap extends StatelessWidget {
  final List<String> subList;
  final TabController tabController;
  final Function(int) onTap;
  const TabbarNavTap({
    super.key,
    required this.subList,
    required this.tabController,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context).colorScheme;
    return Card(
      elevation: 4,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(5),
      ),
      color: theme.primaryContainer,
      child: Padding(
        padding: const EdgeInsets.only(left: 10, right: 10, top: 5, bottom: 5),
        child: TabBar(
          tabs: subList
              .map((e) => Padding(
                    padding: const EdgeInsets.only(bottom: 2),
                    child: Text(e, overflow: TextOverflow.ellipsis),
                  ))
              .toList(),
          dividerColor: Colors.transparent,
          labelColor: theme.primary,
          unselectedLabelColor: theme.onSurface,
          labelStyle: const TextStyle(fontSize: 16),
          unselectedLabelStyle: const TextStyle(fontSize: 16),
          controller: tabController,
          isScrollable: true,
          tabAlignment: TabAlignment.start,
          indicatorPadding: const EdgeInsets.all(0),
          indicatorSize: TabBarIndicatorSize.label,
          onTap: onTap,
        ),
      ),
    );
  }
}
